﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Lab 1 Step by Step Solution</title>
</head>
<body>
    <h2>Entity Framework Learning Labs</h2>
    <h3>Lab 1 Step by Step Solution</h3>
    <p>In order to display the contact name on the site home page, you must 
       first add it to the Customer type in the entity model. The problem 
       stated that the DBA had added the necessary field to the database. 
       This is a clue that you need to update the entity model, so that the 
       new field(s) will be detected and added to your model. The steps are 
       as follows:</p>
    <ol>
        <li>Double-click the Model.edmx file in Solution Explorer (it's in the Models folder).</li>
        <li>In the designer, right-click the design surface and choose Update Model from Database.</li>
        <li>Click Finish. You don't need to change anything else in this dialog box. After a 
            couple seconds, you will notice two new properties have been added to the Customer class.</li>
        <li>Now you just need to add another column to the table on the site index. This is just 
            straight HTML editing. The file you need to change is Views/Home/Index.html. The 
            additions you need to make to the HTML are shown in bold below.</li>
    </ol>
    <pre><code>    &lt;table&gt;
        &lt;thead&gt;
            &lt;tr&gt;&lt;th&gt;Company name&lt;/th&gt;
                <b>&lt;th&gt;Contact name&lt;/th&gt;</b>&lt;/tr&gt;
        &lt;/thead&gt;
        &lt;% foreach (var customer in Model)
           { %&gt;
           &lt;tr&gt;
                &lt;td&gt;&lt;%= Html.Encode(customer.CompanyName) %&gt;&lt;/td&gt;
                <b>&lt;td&gt;&lt;%= Html.Encode(customer.ContactName) %&gt;&lt;/td&gt;</b>
           &lt;/tr&gt;
        &lt;% } %&gt;
    &lt;/table></code></pre>
</body>
</html>
